home *** CD-ROM | disk | FTP | other *** search
- Path: fmsu03.fm.intel.com!frx215!tomtzigt
- From: tomtzigt@frx215.intel.com (Theodore Omtzigt - MPG MAP - FOLSOM)
- Newsgroups: comp.lang.c++
- Subject: const usage as #define
- Date: 14 Feb 1996 01:01:23 GMT
- Organization: Intel Corporation
- Distribution: ca
- Message-ID: <4frc93$2s8@fmsu03.fm.intel.com>
- NNTP-Posting-Host: frx215.fm.intel.com
-
- We are trying to port a piece of C++ code to different platforms.
- The code was developed with GNU g++, but we would like to use
- the native compilers that come with the different platforms.
- On IBM we use c++, on HP we use cfront, and on NT we use VC++.
- Now the following situation arises: given this piece of code
-
- class foo {
- private:
- const int SIZE = 10;
- int array[SIZE];
- public:
- foo();
- };
-
- The intend has probably been to use the 'const int SIZE' like a
- #define macro to parameterize the static allocation of 'array'.
- GNU g++ has no problem with this intend, and IBM c++ also accepts
- this const initializer, but Cfront and VC++ do like the const
- initialization. If you then try to use the foo bla : SIZE(10)
- style to initialize the const int SIZE then you run in the
- problem of not being able to compile int array[SIZE] appropriately.
-
- What is the proper C++ way of doing the above?
-
- Since I don't read this news group regularly, please respond directly
- through email. Thanks in advance,
-
- Theo
- --
- Dr. E. Theodore L. Omtzigt Intel Corporation
- Staff Computer Architect 1900 Prairie City Road
- MAP-Folsom Mail stop: FM5-08
- tel. (916) 356 3696 Folsom, CA 95630
-